<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
        <p>
            user: <input type="text" name="user" id="user">
        </p>
        <p>
            pass: <input type="password" id="pass">
        </p>
        <button id="login">登录</button>
        <button id="reg">注册</button>
    </div>
    <script src="./jquery-3.0.0.min.js"></script>
    <script>
        $('#login').on('click', function() {
            $.ajax({
                type: 'GET',
                url: '/login',
                data: {
                    user: $('#user').val(),
                    pass: $('#pass').val()
                },
                success: function(data) {
                    console.log(data);
                    if (data.ok) {
                        alert(data.msg)
                    } else {
                        alert(data.msg)
                    }
                }
            });
        });

        $('#reg').on('click', function() {
            $.ajax({
                type: 'GET',
                url: '/user',
                data: {
                    act: 'reg',
                    user: $('#user').val(),
                    pass: $('#pass').val()
                },
                success: function (data) {
                    console.log(data);
                }
            });
        });
    </script>
</body>
</html>